package com.itheima.movieDemo;

import java.util.Scanner;

//电影操作类
public class MovieOperator {
    //最好一切数据都用private修饰
    private Movie[] movies;
    //无参构造器
    public MovieOperator() {
    }

    public MovieOperator(Movie[] movies) {
        this.movies = movies;
    }

    public void getAllMovie(){
        for (int i = 0; i < movies.length; i++) {
            System.out.println(movies[i].getId()+" "+movies[i].getName()+" "+movies[i].getPrice()+" "+movies[i].getActor());
        }
    }

    public  void getMovieById(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要查找的id：");
       int id = sc.nextInt();
        for (int i = 0; i < movies.length; i++) {
            Movie m = movies[i];
            if(m.getId()==id){
                System.out.println("查找结果："+m.getId()+" "+m.getName()+" "+m.getPrice()+" "+m.getActor());
            }
        }

    }

}
